package finetune

import (
	"chatgpt/ai/models"
	openai2 "chatgpt/ai/openai"
	"chatgpt/helper/code"
)

func RemoteFineTuneList() (code.CODENO, []map[string]any) {
	rcode, res := openai2.RemoteApi(openai2.OPENAI_FINE_TUNE_LIST, "", nil)
	if rcode != code.SUCCESS {
		return rcode, []map[string]any{}
	}
	dataarr, ok := res.Data.([]any)
	if !ok {
		return rcode, []map[string]any{}
	}
	datam := []map[string]any{}
	for _, v := range dataarr {
		obj := v.(map[string]any)
		mname := obj["fine_tuned_model"].(string)
		datam = append(datam, map[string]any{
			"BaseModel": obj["model"].(string),
			"Model":     mname,
			"Desc":      "自定义模型 " + mname,
			"Avatar":    "",
		})
	}
	return rcode, datam
}

func FineTuneList(force bool) (code.CODENO, []map[string]any) {

	return models.ConfModels(force)
}
